//
//  StockInOutTarget.swift
//  TestAPIManager
//
//  Created by yq on 2020/10/21.
//  Copyright © 2020 杨庆. All rights reserved.
//

import Foundation
import Moya

enum StockInOutTarget {

    /// 获取移动设备入库单列表
    case appSearchWarehouseStockIn(pageNum: Int)
    /// 查看入库单
    case appGetWarehouseStockIn(warehouseStockInId: String)
    /// 获取出库单列表
    case appSearchWarehouseStockOut(pageNum: Int)
    /// 查看出库单
    case appGetWarehouseStockOut(warehouseStockOutId: String)
}


extension StockInOutTarget:TargetType {
    
    var baseURL: URL {
        return URL(string: "https://www.baidu.com")!
    }
    
    var path: String {
        switch self {
        case .appSearchWarehouseStockIn:
            return "/api/customerStockIn/appSearchWarehouseStockIn"
        case .appGetWarehouseStockIn:
            return "/api/customerStockIn/appGetWarehouseStockIn"
        case .appSearchWarehouseStockOut:
            return "/api/customerStockOut/appSearchWarehouseStockOut"
        case .appGetWarehouseStockOut:
            return "/api/customerStockOut/appGetWarehouseStockOut"
        }
    }
    
    var method: Moya.Method {
        return .post
    }
    
    var sampleData: Data {
        return "".data(using: String.Encoding.utf8)!
    }
    
    var task: Task {
        guard let params = parameters else { return .requestPlain}
        return  .requestParameters(parameters: params, encoding: JSONEncoding.default)

    }
    
    var headers: [String : String]? {
        return nil
    }
    
    
    var parameters: [String : Any]? {
          switch self {
          case .appSearchWarehouseStockIn(let pageNum):
              return ["pageNum": pageNum, "pageSize": 15]
          case .appGetWarehouseStockIn(let warehouseStockInId):
              return ["warehouseStockInId": warehouseStockInId]
          case .appSearchWarehouseStockOut(let pageNum):
              return ["pageNum": pageNum, "pageSize": 15]
          case .appGetWarehouseStockOut(let warehouseStockOutId):
              return ["warehouseStockOutId": warehouseStockOutId]
          }
      }
    
}
